<html>

<head>
 <link rel="stylesheet" type="text/css" href="doc-styles.css"></link>
 <title>glScript Default Extensions</title>  
</head>

<body>
<h3>glScript Default Extensions</h3>

<a href="index.html">Index</a>

<h4>glScript Default Extensions</h4>
<p>
Following default extensions are provided with glScript version 0.0.0.7.
</p>

<ul>
 <li>glu</li>
 <li>obj</li>
 <li>img</li>
</ul>

<hr />

<h4>glu</h4>
<p><i>
Capabilities: library<br>
Version: 0.1
</i></p>

<p>
<code>glu</code> is a library extension that provides basic support for OpenGL Utility library (glu). Current 
version supports only few APIs related to quadric objects and drawing objects like shpere, disk, partial disk 
and cylinder. Following methods are provided:
</p>
<pre><code>gluNewQuadric
gluQuadricDrawStyle
gluQuadricNormals
gluQuadricTexture
gluQuadricOrientation
gluQuadricDrawStyle
gluCylinder
gluDisk
gluPartialDisk
gluSphere
</code></pre>

Example:
<pre><code>var glu = gls.require ("glu");
var q1;

function gls_init () {
	q1 = glu.gluNewQuadric ();
}	

function gls_terminate () {
	glu.gluDeleteQuadric (q1);
}

function gls_renderScene () {
	glu.gluSphere (q1, 0.5, 20, 20);
}
</code></pre>

<p>
You may want to check the <a href="sample-programs/glu-demo.gls">glu-demo.gls</a> sample script for full example.
For complete OpenGL Utility API reference, please refer <a href="http://www.opengl.org/documentation/" target="_blank">
OpenGL glu reference</a>&nbsp;...
</p>

<hr />

<h4>obj</h4>
<p><i>
Capabilities: library<br>
Version: 0.1
</i></p>
<p>
<code>obj</code> is a library extension that provides inbuilt support for loading and rendering OBJ format 
3D models. Current version of <code>obj</code> does not support textures.
</p>

<h5>Methods</h5>
<div class="methods">
  <div class="method">
	<div class="syntax">load (path)</div>
    <div class="doc">
		<p>Loads a model from a file and returns a new model object, which can be used to render the model 
		as shown below.
		</p>
		<p>Example to load a model from a file cube.obj and render it:</p>
		<p><code>
		var obj = gls.require ("obj");<br />
		var cube = obj.load ("cube.obj");<br /><br />
		cube.render ();
		</code></p>
		<p>You can also get the bounding box of the model as shown below:</p>
		<p><code>
		var BB = cube.boundingBox;<br />
		console.log ( <br />
			'width:' + BB.width + ' height:' + BB.height + ' depth:' + BB.depth <br />
			);
		</code></p>
	</div>
  </div>
</div>

<p>
You may want to check the <a href="sample-programs/obj-demo.gls">obj-demo.gls</a> sample script for full example.
</p>

<h4>img</h4>
<p><i>
Capabilities: library<br>
Version: 0.2
</i></p>
<p>
<code>img</code> is a library extension that provides basic support for loading and rendering images using texture
map. Current version supports following image formats:

<ul>
<li>BMP 8 bit RGB</li>
<li>BMP 16 bit RGB</li>
<li>BMP 24 bit RGB</li>
<li>PNG</li>
<li>JPG</li>
</li>
</ul>

<p>
Following methods are provided:
</p>
<h5>Methods</h5>
<div class="methods">
  <div class="method">
	<div class="syntax">load (image_path)</div>
    <div class="doc">
		<p>
		Loads an image from a file and returns a new image object.
		</p>
		
		<p>Example to load an image from a file:</p>
		<p><code>
		var img = gls.require ("img");<br />
		var image1 = img.load ("brick.bmp");<br />
		</code></p>
		<p>You can change the origin and size of the image as shown below:</p>
		<p><code>
		image1.x = 0.0;<br />
		image1.y = 0.0;<br /><br />
		image1.width = 2.0;<br />
		image1.height = 2.0;
		</code></p>
		
		<p>Finally, render the image using its render method:</p>
		<p><code>
		image.render ();
		</code></p>
		
		<p><strong>Notes:</strong><br />
		<code>img</code> library assumes 2D coordinate system to render the image. So, necessary transformations has
		to be applied to render the image in proper size in 3D / perspective viewing mode. Please refer the 
		example script on how to do this.
		</p>
	</div>
  </div>
<div>
<p>
Please check the <a href="sample-programs/img-demo.gls">img-demo.gls</a> sample script for complete example.
</p>

<div class="footer">
OpenGL is a registered trademark of Silicon Graphics, Inc.
</div>
</body>
</html>
